<template>
  <view>
    <scroll-view class="list-box" scroll-y @scrolltolower="toLower">
      <list-card v-for="item in list" :key="item.id" :item="item.courseResp" />
      <van-empty v-if="!list.length" description="暂无收藏数据" />
    </scroll-view>
  </view>
</template>
  
  <script>
import ListCard from "@/components/Card/index.vue";
import { CollectList } from "@/api/course/course.js";
export default {
  components: {
    ListCard,
  },
  data() {
    return {
      searchForm: {
        pageCurrent: 1,
        pageSize: 15,
      },
      list: [],
    };
  },
  onLoad() {},
  onShow() {
    this.searchForm.pageCurrent = 1;
    this.list = [];
    this.getList();
  },
  methods: {
    toLower() {
      if (this.searchForm.pageCurrent < this.total) {
        this.searchForm.pageCurrent += 1;
        this.getList();
      }
    },
    getList() {
      CollectList(this.searchForm).then((res) => {
        if (res.code === 200) {
          this.list = this.list.concat(res.data.list);
          this.total = res.data.totalPage;
        }
      });
    },
  },
};
</script>
  
<style scoped>
.list-box {
  width: calc(100vw - 40rpx);
  padding: 0 20rpx;
  height: calc(100vh - 140rpx);
}
</style>
  